package com.action
{
	import com.greensock.TweenLite;
	import com.stage.item.Player;
	
	public class ActionTurn extends BaseAction
	{
		public function ActionTurn(player:Player, data:Object=null)
		{
			super(player, data);
			_type = TURN;
		}
		
		public override function start(dir:int=1):void{
			if(player.dir != dir){
				TweenLite.to(player.view, 2, {turnDir:180 * dir, onComplete:turnComplete});
			}
		}
		
		private function turnComplete():void{
			turnOver();
			actionCallback(); // 动作结束的回调
		}
		
		private function turnOver():void{
			if(player.view.turnDir > 0){
				player.dir = 1;
			}else if(player.view.turnDir < 0){
				player.dir = -1;
			}
			player.view.turnDir = 0;
		}
		
		public override function end():void{
			turnOver();
		}
	}
}